import React, { useEffect, useState } from 'react'
import MyHead from '../../components/MyHead'
import { Button, List, Space, Swiper, Toast } from 'antd-mobile'
import Good from '../Good/Good'
import { Http } from '../../api'

const Home = ({

}) => {
  const [banner,setBanner] = useState<any>([])
  const [list,setList] = useState<any>([])

  const getNewBanner = async()=>{
    let res:any = await Http.getBanner()  //调接口 获取banner 数据
    setBanner(res.banners)
  }
  useEffect(()=>{
    getNewBanner() //调方法
  },[])
  return (
    <div>
      <MyHead title="首页" back={false} />
      <Swiper autoplay loop allowTouchMove>
           {/* 循环轮播图里得数据 */}
      {
       banner.map((item:any,index:any)=>{
        return(
          <Swiper.Item key={index} >
            <img src={item.imageUrl} alt="" style={{width:'100%',}}  />
          </Swiper.Item>
        )
       })
      }
        
      </Swiper>
    </div>
  )
}

export default Home